import type { App } from "vue";
export const setUpDirectives = (app: App<Element>) => {
  app.directive("focus", {
    // 当被绑定的元素插入到DOM中的时候……
    mounted(el) {
      console.log("🚀 ~ mounted ~ el:", el);
      // 聚焦元素
      el.focus();
    },
  });
  app.directive("setColor", {
    // 当被绑定的元素插入到DOM中的时候……
    mounted(el, binding) {
      console.log("🚀 ~ mounted ~ el:", el);
      console.log("🚀 ~ mounted ~ binding:", binding);

      // 根据指令的值来设置字体颜色
      if (binding.value) {
        el.style.color = binding.value;
      } else {
        el.style.color = "red"; // 默认设置为红色
      }
    },
  });
};
